package br.com.pfc.mobile;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import br.com.pfc.mobile.activity.CadastroClienteActivity;
import br.com.pfc.mobile.activity.EmissaoPedidoActivity;
import br.com.pfc.mobile.transferobject.UsuarioTO;
import br.com.pfc.mobile.util.MobileSession;


public class ActivityPrincipal extends Activity {
	public static final int PEDIDO = 0;
	public static final int CLIENTE = 1;
	 @Override
	    public void onCreate(Bundle savedInstanceState) {
	    	
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.principal);
	        MobileSession sessao = MobileSession.getInstance();
	        Map mapa = sessao.getSessao();
	        UsuarioTO us = (UsuarioTO) mapa.get("usuarioLogado");
	        TextView nome = (TextView) findViewById(R.id.usLog);
	        nome.setText(us.getNome());
	        Log.i("PFC",us.getLogin());
	 }
	 
	 @Override
	 public boolean onCreateOptionsMenu(Menu menu){
		 super.onCreateOptionsMenu(menu);
		 menu.add(0, PEDIDO, 0, "Pedido").setIcon(R.drawable.pedido);
		 menu.add(0, CLIENTE, 0, "Cliente").setIcon(R.drawable.cliente);
		 return true;
	 }
	 
	 @Override
	 public boolean onMenuItemSelected(int featureId,MenuItem item){
		 switch (item.getItemId()) {
		 case PEDIDO:
			 	//Toast.makeText(ActivityPrincipal.this, "Menu Pedido selecionado", Toast.LENGTH_LONG).show();
			 	startActivity(new Intent(ActivityPrincipal.this,EmissaoPedidoActivity.class));
			 break;
		 case CLIENTE:
			 startActivity(new Intent(ActivityPrincipal.this,CadastroClienteActivity.class));
			 break;

		 }
		 return false;
	 }
}
